<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <link href="../css/bootstrap.css" rel="stylesheet">
    <link href="../css/font-awesome.css" rel="stylesheet">
    <link href="../css/custom-styles.css" rel="stylesheet">
    <link href="../css/element/index.css" rel="stylesheet">
    <style>
        [v-cloak]{
            display:none;
        }
    </style>
</head>
<body>
<div id="wrapper" v-cloak>
    <div class="row">
        <div class="col-md-12" style="height: 60px;">
            <nav class="navbar navbar-default top-navbar">
                <div class="row">
                    <div class="col-md-2">
                        <a class="navbar-brand" style="width: 100%;background-color: darkslateblue" href="index.html">
                            <strong style="font-size: 20px;">电影订票购票系统</strong>
                        </a >
                    </div>
                    <div class="col-md-10">
                        <div class="navbar-header">
                            <a href="/front/index.html" style="color: white;line-height: 60px;font-size: 16px;margin-left: 30px">
                                <i class="fa fa-desktop"></i>
                            </a >
                        </div>
                        <ul class="nav navbar-top-links navbar-right">
                            <li style="color:white">欢迎您,{{user.name}}</li>
                            <li class="dropdown">
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                    <i class="fa fa-user fa-fw"></i>
                                    <i class="fa fa-caret-down"></i>
                                </a >
                                <ul class="dropdown-menu dropdown-user">
                                    <li>
                                        <a href="javascript:void(0)" @click="personalPage">
                                            <i class="fa fa-user fa-fw"></i>个人信息
                                        </a >
                                    </li>
                                    <li class="divider"></li>
                                    <li>
                                        <a href="javascript:void(0)" @click="logout">
                                            <i class="fa fa-sign-out fa-fw"></i>退出
                                        </a >
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
            <nav id="nav-id" class="navbar-default navbar-side">
                <div class="sidebar-collapse">
                    <ul class="nav" id="main-menu">
                        <li>
                            <a href="index.html"> <i class="fa fa-dashboard"></i>首页</a>
                        </li>
                        <li>
                            <a href="#"> <i class="fa fa-sitemap"></i>信息管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-second-level collapse in">
                                <li v-if="authority.indexOf(1) !== -1">
                                    <a href="adminInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">管理员信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(3) !== -1">
                                    <a href="userInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">用户信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(4) != -1">
                                    <a href="messageInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">在线交流信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000001) != -1">
                                    <a href="advertiserInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">公告信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000003) != -1">
                                    <a href="linkInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">友情链接</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000015) != -1">
                                    <a href="goodsInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">电影详情信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000016) != -1">
                                    <a href="cartInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">收藏栏信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000017) != -1">
                                    <a href="orderInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">订单信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000018) != -1">
                                    <a href="commentInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">评价信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000014) != -1">
                                    <a href="typeInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">电影类型信息</span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0) " @click="personalPage" class="active-menu">
                                        <i class="fa fa-user"></i>个人信息
                                    </a >
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="updataPassword.html"> <i class="fa fa-unlock-alt"></i>修改密码</a>
                        </li>
                        <li>
                            <a href="javascript:void(0)" @click="logout"><i class="fa fa-power-off"></i>退出登录</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="col-md-10" style="background-color: #e6e6e6">
            <div id="page-wrapper">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-default" style="background-color: whitesmoke">
                            <div class="panel-heading" style="margin-bottom: 10px;background-color: whitesmoke">
                                个人信息
                            </div>
                            <input type="hidden" v-model="entity.id">
                            <div class="panel-body">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">姓名</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.name" placeholder="请输入姓名" id="name">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">昵称</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.nickName" placeholder="请输入昵称" id="nickName">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">性别</label>
                                        <div class="col-sm-7">
                                             <label class="radio-inline">
                                                 <input type="radio" value="男" v-model="entity.sex">男
                                             </label>
                                            <label class="radio-inline">
                                                <input type="radio" value="女" v-model="entity.sex">女
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">年龄</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.age" placeholder="请输入年龄" id="age">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">生日</label>
                                        <div class="col-sm-7">
                                            <el-data-picker v-model="entity.birthday" id="birthday" type="datetime" clearable value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间" ></el-data-picker>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">手机号</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.phone" placeholder="请输入手机号" id="phone">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">地址</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.address" placeholder="请输入地址" id="address">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">邮政编码</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.code" placeholder="请输入邮政编码" id="code">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">电子邮箱</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.email" placeholder="请输入电子邮箱" id="email">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">身份证</label>
                                        <div class="col-sm-7">
                                            <input type="text" class="form-control" v-model="entity.cardId" placeholder="请输入身份证" id="cardId">
                                        </div>
                                    </div>
                                    <div style="text-align: center">
                                        <button type="button" class="btn btn-primary" v-on:click="update()">保存</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../js/jquery-1.10.2.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.metisMenu.js"></script>
<script src="../js/custom-scripts.js"></script>
<script src="../js/my.js"></script>
<script src="../js/vue2.6.11/vue.min.js"></script>
<script src="../js/vue2.6.11/axios.js"></script>
<script src="../js/echarts.min.js"></script>
<script src="../js/element/index.js"></script>
<script>
    new Vue({
        el: "#wrapper",
        data: {
            user: {},
            authority: [],
            entity: {
                sex: '男'
            }
        },
        created: function () {
            this.user = JSON.parse(localStorage.getItem('user'));
            axios.get("/authority").then(res => {
                if (res.data.code === '0') {
                    this.authority = res.data.data;
                } else {
                    alert(res.data.msg);
                }
            });
            this.loadData();
        },
        method: {
            //从后端获取当前登录用户的信息
            loadData(){
                axios.get("/getAccountInfo").then(res => {
                    if (res.data.code === '0') {
                        this.entity = res.data.data;
                    } else {
                        alert(res.data.msg);
                    }
                });
            },
            //保存个人信息
            update(){
                axios.put("/userInfo",this.entity).then(res => {
                    if (res.data.code === '0') {
                        alert("更新成功");
                        this.loadData();
                    } else {
                        alert(res.data.msg);
                    }
                });
            }
        }
    });
</script>
</body>
</html>